package cn.qiao.mq.controller;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * desc:
 *
 * @author qiao
 * @date 2023年06月05日 22:17
 */
@RestController
@RequestMapping("rocket")
public class RocketController {


    @Autowired
    private RocketMQTemplate rocketMQTemplate;


    /**
     * 通过 convertAndSend  方法发送一个普通的消息
     * @param msg
     * @return
     */
    @GetMapping
    public String sent(String msg){
        rocketMQTemplate.convertAndSend("test_topic","这是一个测试消息");
        return "";
    }

    @GetMapping("/rocket/tagA")
    public void tagA() {
        rocketMQTemplate.convertAndSend("test_topic:tagA", "hello world tagA");
    }

    @GetMapping("/rocket/tagB")
    public void tagB() {
        rocketMQTemplate.convertAndSend("test_topic:tagB", "hello world tagB");
    }


}
